package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.AbstractAccount;

public class CheckingAccount extends AbstractAccount {
	private boolean flag;
	private double maximumAmountToWithdraw;

	public CheckingAccount(double initial, double overdraft) {
		super(initial, overdraft);
	}

	@Override
	public void deposit(double amount) {
		balance += amount;
	}

	@Override
	public void withdraw(double amount) {
		if (amount > balance) {
			overdraft -= (amount - balance);
			balance = overdraft;
			flag = true;
		} else {
			balance -= amount;
		}

	}

	@Override
	public void getBalance() {
		if (flag == true) {
			System.out.println("overdraft value: " + balance);
		} else {
			System.out.println("overdraft value: " + overdraft + "; balance: "
					+ balance);
		}
	}

	@Override
	public double maximumAmountToWithdraw() {
		maximumAmountToWithdraw = balance;
		return maximumAmountToWithdraw;
	}

}
